package com.youle.askdao.common.result;

public class ResultUtil {
    private ResultUtil() {
    }

    /**
     * 带参数的成功状态
     *
     * @param object：入参
     * @return
     */
    public static <T> Result success(T object) {
        Result result = new Result<T>();
        result.setErrorCode("0");
        result.setMsg("success");
        result.setData(object);
        return result;
    }

    /**
     * 不带参数的成功状态
     *
     * @return
     */
    public static Result success() {
        Result result = new Result();
        result.setErrorCode("0");
        result.setMsg("success");
        return result;
    }

    /**
     * 错误状态
     *
     * @param errorCode：错误码
     * @param msg：错误的信息
     * @return
     */
    public static Result error(String errorCode, String msg) {
        Result result = new Result();
        result.setErrorCode(errorCode);
        result.setMsg(msg);
        return result;
    }
}
